﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.ComponentModel;

namespace TA.Turbo.Controls
{
	public class SelectionNode : BaseTextNode
	{
		#region PUBLIC
		#region INIT
		/// <summary>
		/// Ctor.
		/// </summary>
		public SelectionNode()
		{
			this.Value = "";
		}
		#endregion
		#region EVENTS
		#endregion
		#region PROPS
		[DefaultValue("")]
		[NotifyParentProperty(true)]
		public string Value { get; set; }
		#endregion
		#region METHODS
		#endregion
		#endregion
		#region INTERNAL
		#region PROPS
		protected override TreeNodeType Type
		{
			get { return TreeNodeType.Selection; }
		}
		#endregion
		#region METHODS
		#region RENDER
		protected override void RenderContentsMain(TreeView owner, TreeNodePosition position, int level, HtmlTextWriter writer)
		{
			writer.AddAttribute(HtmlTextWriterAttribute.Href, "");
			writer.RenderBeginTag(HtmlTextWriterTag.A);

			writer.Write(this.Text);

			writer.RenderEndTag();
		}
		#endregion
		#region JSON
		public override void SerializeContents(TA.JSON.JsonWriter jw)
		{
			base.SerializeContents(jw);

			if (!string.IsNullOrEmpty(this.Value))
			{
				jw.PropertyName("V");
				jw.Value(this.Value);
			}
		}
		public override void DeserializeContent(TA.JSON.IJsonReader jr, string propShortName)
		{
			switch (propShortName)
			{
				case "V": this.Value = (string)jr.Value; break;
				default:
					base.DeserializeContent(jr, propShortName);
					break;
			}
		}
		#endregion
		#endregion
		#endregion

	}
}
